package com.nsl.my_youlai.mystar;

public class NslUtilString {
    /**
     * 输入 a,b,c ，发挥 c
     * @param sourceString
     * @param separator
     * @return
     */
    public static String getLastFragment(String sourceString,String separator){
        int lastIndex=sourceString.lastIndexOf(separator);
        if(lastIndex==-1){
            return sourceString;
        }else{
            return sourceString.substring(lastIndex+1);
        }
    }

    public static boolean notNullAndTrimBlank(String s){
        return s !=null && !s.trim().equals("");
    }

    public static void main(String[] args) {
        String s1="\\abc\\11.xls";
        String s2="\\11.xls";
        String s3="11.xls";
        System.out.println(getLastFragment(s1,"\\"));
        System.out.println(getLastFragment(s2,"\\"));
        System.out.println(getLastFragment(s3,"\\"));

        System.out.println(NslUtilFilePath.getFileName(s1));
        System.out.println(NslUtilFilePath.getFileName(s2));
        System.out.println(NslUtilFilePath.getFileName(s3));

        System.out.println(NslUtilFilePath.getFileNameWithoutExtension(s1));
        System.out.println(NslUtilFilePath.getFileNameWithoutExtension(s2));
        System.out.println(NslUtilFilePath.getFileNameWithoutExtension(s3));


    }
}
